<?php
/* -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
# ***** BEGIN LICENSE BLOCK *****
# This file is part of Plume CMS, a website management application.
# Copyright (C) 2001-2007 Loic d'Anterroches and contributors.
#
# Plume CMS is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# Plume CMS is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
#
# ***** END LICENSE BLOCK ***** */

$ctl = array();
$base = Pluf::f('cms_base', '');
$admin_pfx =  Pluf::f('prefix_admin', '/admin');
$blog_pfx =  Pluf::f('prefix_blog', '/blog');

// --- blog public views ------
$blog_views = array()
$blog_views[] = array('regex' => '#^/$#',
                      'priority' => 4,
                      'base' => $base,
                      'model' => 'CMS_Views_Blog',
                      'method' => 'main');

$blog_views[] = array('regex' => '#^(.*)$#',
                      'priority' => 5, // We grab the remaining URLs
                                       // at the end as it contains
                                       // the slug.
                      'base' => $base,
                      'model' => 'CMS_Views_Blog',
                      'method' => 'viewPost');

$ctl = array_merge($ctl, 
                   Pluf_Dispatcher::addPrefixToViews($blog_pfx, $blog_views));

// --- blog admin views ------
$blog_views = array()
$blog_views[] = array('regex' => '#^/blog/$#',
                      'priority' => 4,
                      'base' => $base,
                      'precond' => 'CMS_Precondition::blogAdmin',
                      'model' => 'CMS_Views_Blog',
                      'method' => 'adminMain');

$blog_views[] = array('regex' => '#^/blog/post/$#',
                      'priority' => 4,
                      'base' => $base,
                      'precond' => 'CMS_Precondition::blogAdmin',
                      'model' => 'CMS_Views_Blog',
                      'method' => 'adminListPost');

$blog_views[] = array('regex' => '#^/blog/post/add/$#',
                      'priority' => 4,
                      'base' => $base,
                      'precond' => 'CMS_Precondition::blogAdmin',
                      'model' => 'CMS_Views_Blog',
                      'method' => 'adminAddPost');

$blog_views[] = array('regex' => '#^/blog/post/(\d+)/delete/$#',
                      'priority' => 4,
                      'base' => $base,
                      'precond' => 'CMS_Precondition::blogAdmin',
                      'model' => 'CMS_Views_Blog',
                      'method' => 'adminDeletePost');

$blog_views[] = array('regex' => '#^/blog/post/(\d+)/$#',
                      'priority' => 4,
                      'base' => $base,
                      'precond' => 'CMS_Precondition::blogAdmin',
                      'model' => 'CMS_Views_Blog',
                      'method' => 'adminEditPost');
$ctl = array_merge($ctl, 
                   Pluf_Dispatcher::addPrefixToViews($admin_pfx, $blog_views));

return $ctl;
